package org.future.wsdl.data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;


/**
 * xs:schame 元素信息
 * @author dycc
 *
 */
public class XSchema {
    
    private String tagName;
    
    private Map<String,String> map_attr = new HashMap<String,String>();
    
    private List<String> importNsList = new ArrayList<String>();
    
    private List<XComplexType> complexTypeList = new ArrayList<XComplexType>();
    
    private List<XElement> elementList = new ArrayList<XElement>();
    
    // tagName
    public String getTagName() {
        return tagName;
    }
    public void setTagName(String tagName) {
        this.tagName = tagName;
    }
    // map_attr
    public Map<String, String> getMap_attr() {
        return map_attr;
    }
    public void setMap_attr(Map<String, String> mapAttr) {
        map_attr = mapAttr;
    }
    // import namespace list
    public List<String> getImportNsList() {
        return importNsList;
    }
    public void setImportNsList(List<String> importNsList) {
        this.importNsList = importNsList;
    }
    // complexTypeList
    public List<XComplexType> getComplexTypeList() {
        return complexTypeList;
    }
    public void setComplexTypeList(List<XComplexType> complexTypeList) {
        this.complexTypeList = complexTypeList;
    }
    // elementList
    public List<XElement> getElementList() {
        return elementList;
    }
    public void setElementList(List<XElement> elementList) {
        this.elementList = elementList;
    }
    
    /**
     * toString
     */
    public String toString(){
       StringBuffer sb = new StringBuffer();
       sb.append("<" + tagName);
       Iterator<String> it_attr = map_attr.keySet().iterator();
       while(it_attr.hasNext()){
           String name = it_attr.next();
           String val = map_attr.get(name);
           sb.append(" " + name +  "=\"" + val + "\"");
       }
       sb.append(">");
       sb.append("\n");
       // add imports
       for(int i=0;i<importNsList.size();i++){
           String ns = importNsList.get(i);
           sb.append("<xs:import namespace=\"" + ns + "\"" + " />");
           sb.append("\n");
       }
       // add complexType
       for(int i=0;i<complexTypeList.size();i++){
           sb.append(complexTypeList.get(i));
           sb.append("\n");
       }
       // add element
       for(int i=0;i<elementList.size();i++){
           sb.append(elementList.get(i));
           sb.append("\n");
       }
       sb.append("</" + tagName + ">");
       return sb.toString();
    }
}
